<!doctype html>
<%@ page contentType="text/html;charset=utf-8" pageEncoding="utf-8"
         language="java" %>
<%@ include file="/jsp/mobile/include/include.jsp" %>
<html>
<head>
    <title>请您付款</title>
    <%@ include file="/jsp/mobile/include/header.jsp" %>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/style/mobile/style0809.css"/>
    <script src="<%=request.getContextPath()%>/script/fastclick.js"></script>
    <!-- <script type="text/javascript"
            src="https://api.map.baidu.com/getscript?v=2.0&ak=ZqLcjwGpzoTcFapLnGDxeM92jPGUVtks&services=false&t=20160727152532"></script> -->
    <script type="text/javascript">
        //判断是否移动端
        if(!navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){
            window.location.href = "<%=request.getContextPath()%>/jsp/mobile/offline/error.jsp?errorMsg=访问出错";
        }
        /* if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(function (p) {
                        var latitude = p.coords.latitude//纬度
                        var longitude = p.coords.longitude;
                        var point = new BMap.Point(longitude, latitude);  // 创建坐标点
                        // 根据坐标得到地址描述
                        var myGeo = new BMap.Geocoder();
                        myGeo.getLocation(point, function (result) {
                            var city = result.addressComponents.city;
                            var street_number = result.addressComponents.street_number;
                            var street = result.addressComponents.street;
                            var district = result.addressComponents.district;
                            $("#address").html(city+district);
                        });
                    }, function (e) {//错误信息
                        $("showAddr").hide();
                    }
            );
        } */
    </script>
</head>
<body>
<div class="main" id="main">
    <div class="adts" id="showAddr"><!-- <i class="icov icov13"></i> --><span id="address"></span></div>
    <div class="inSum inSum2">
        <p class="ti"><c:out value="${model.merchantShortName}"/></p>
        <p class="ci">￥<span id="inputAmt">0.00</span></p>
    </div>
    <div class="tpXs tpXs2">
        <p class="f14">请向收银员询问应付金额 </p>
        <p>宝数收银台@baoshuxinxxi.com</p>
    </div>
    <div class="inPt">
        <table>
            <tr>
                <td width="25%"><span>7</span></td>
                <td width="25%"><span>8</span></td>
                <td width="25%"><span>9</span></td>
                <td width="25%"><span><i class="icov icov3"></i></span></td>
            </tr>
            <tr>
                <td><span>4</span></td>
                <td><span>5</span></td>
                <td><span>6</span></td>
                <td rowspan="3"><a href="#" id="confirmAmt" class="czt">付款</a></td>
            </tr>
            <tr>
                <td><span>1</span></td>
                <td><span>2</span></td>
                <td><span>3</span></td>
            </tr>
            <tr>
                <td colspan="2"><span>0</span></td>
                <td><span>.</span></td>
            </tr>
        </table>
    </div>
</div>

<input id="originalStatus" name="originalStatus" type="hidden" value="1"> <!--是否为原始状态-->
<input id="merchantId" value="${model.merchantId}" type="hidden">

<script type="text/javascript">
    //-->
    $(function () {
        FastClick.attach(document.body);
    });
    $("td span").bind("click", function () {
        var _amt = $("#inputAmt").text();
        var _originalStatus = $("#originalStatus").val();
        var _back = $(this).has("i").length;//有 i标签为回退键
        if (!_back) {
            var _value = $(this).text();
            if (_originalStatus == "1" || _amt == '0.00')//如果为原始状态 需要0.00清掉 同时设置为已改动
            {
                setDealAmt(_value);
                $("#originalStatus").val("0");
            }else {
                setDealAmt(_amt + _value);
            }
        } else {
            //如果删除到最后数值则一直保持0.00
            if (_amt.length <= 1 || _amt == '0.00') {
                $("#originalStatus").val("1"); //保持为原始状态
                setDealAmt("0.00");
            } else {
                setDealAmt(_amt.substr(0, _amt.length - 1));
            }
        }
    });

    function setDealAmt(amt) {
        changeStyleByValue(amt);
    }
    
    function income() {
        var merchantId='${model.merchantId}';
        var _amt = $("#inputAmt").text();
        var _agentType=agentType();
        var url=getBasePath()+"/mobile/offline/next?merchantId="+merchantId+
            "&amount="+_amt+"&payType="+_agentType;
        window.location.href=url;
    }

    function changeStyleByValue(amt) {
        var _amt = amt;
        $("#inputAmt").text(amt);
        if (checkPrice(_amt) && parseFloat(_amt) > 0) {
            $("#confirmAmt").css("color","#000").attr("href",
                    "javascript:income();");
        } else {
            $("#confirmAmt").css("color","").removeAttr("href");
        }
    }
</script>
</body>
</html>
